//
//  EpointViewControllerBase.m
//  iphone.mobileoa
//
//  Created by 李亚春 on 13-5-22.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "EpointViewControllerBase.h"
#import "TKAlertCenter.h"

#import "EpointTask.h"

@interface EpointViewControllerBase()
{
    MBProgressHUD *MBPHUD;
}

@end

@implementation EpointViewControllerBase

-(id)initWithParams:(NSMutableDictionary*)params
{
    self = [super init];
    if (self) {
        initParam = params;
    }
    return self;
}

-(void)startTask:(NSString *)TaskClassName withParams:(NSMutableDictionary *)params withTaskId:(int)TaskId
{
    EpointTask *c = [[NSClassFromString(TaskClassName) alloc]initWithContext:self andParams:params andTaskId:TaskId];
    [c startInvokeTask];
}

#pragma Toast

-(void)toastMessage:(NSString *)msg
{
    [[TKAlertCenter defaultCenter] postAlertWithMessage:msg];
}

-(void)toastMessage:(NSString *)msg withImage:(UIImage *)img
{
    [[TKAlertCenter defaultCenter]postAlertWithMessage:msg image:img];
}

-(void)showMBPHUD
{
    MBPHUD = [[MBProgressHUD alloc]initWithView:self.view];
	[self.view addSubview:MBPHUD];
//    MBPHUD.delegate = self;
    [MBPHUD show:YES];
}

-(void)showMBPHUDWithMessage:(NSString *)_message
{
    MBPHUD = [[MBProgressHUD alloc]initWithView:self.view];
	[self.view addSubview:MBPHUD];
//    MBPHUD.delegate = self;
    MBPHUD.labelText = _message;
    [MBPHUD show:YES];
}

-(void)hideMBPHUD
{
    if(![MBPHUD isHidden]){
        [MBPHUD hide:YES];
    }
}

@end
